using System;
using System.ComponentModel;
using System.Threading;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Interfaces;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.Respondents;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.OperationContracts
{
    public partial class InventoryServiceClient
    {

        #region GetWarehouseCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Warehouse>> GetWarehouseCollectionCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetWarehouseCollection(bool isShowAll, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetWarehouseCollection(isShowAll, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Warehouse> IInventoryService.EndGetWarehouseCollection(IAsyncResult result)
        {
            return Channel.EndGetWarehouseCollection(result);
        }

        private IAsyncResult OnBeginGetWarehouseCollection(object[] inValues, AsyncCallback callback, object asyncState)
        {
            bool isShowAll = (bool)inValues[0];

            return ((IInventoryService)(this)).BeginGetWarehouseCollection(isShowAll, callback, asyncState);
        }

        private object[] OnEndGetWarehouseCollection(IAsyncResult result)
        {
            CollectionFeedback<Warehouse> retVal = ((IInventoryService)(this)).EndGetWarehouseCollection(result);
            return new object[] { retVal };
        }

        private void OnGetWarehouseCollectionCompleted(object state)
        {
            if ((GetWarehouseCollectionCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetWarehouseCollectionCompleted(this, new CollectionFeedbackCompletedEventArgs<Warehouse>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetWarehouseCollectionAsync(bool isShowAll)
        {
            GetWarehouseCollectionAsync(isShowAll, null);
        }

        public void GetWarehouseCollectionAsync(bool isShowAll, object userState)
        {
            if ((onBeginGetWarehouseCollectionDelegate == null))
            {
                onBeginGetWarehouseCollectionDelegate = new BeginOperationDelegate(OnBeginGetWarehouseCollection);
            }
            if ((onEndGetWarehouseCollectionDelegate == null))
            {
                onEndGetWarehouseCollectionDelegate = new EndOperationDelegate(OnEndGetWarehouseCollection);
            }
            if ((onGetWarehouseCollectionCompletedDelegate == null))
            {
                onGetWarehouseCollectionCompletedDelegate = new SendOrPostCallback(OnGetWarehouseCollectionCompleted);
            }
            InvokeAsync(onBeginGetWarehouseCollectionDelegate, new object[] {
                    isShowAll}, onEndGetWarehouseCollectionDelegate, onGetWarehouseCollectionCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetWarehouseCollectionDelegate;

        private EndOperationDelegate onEndGetWarehouseCollectionDelegate;

        private SendOrPostCallback onGetWarehouseCollectionCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetWarehouseCollection(bool isShowAll, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = isShowAll;

                IAsyncResult _result = BeginInvoke("GetWarehouseCollection", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Warehouse> EndGetWarehouseCollection(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Warehouse> _result = ((CollectionFeedback<Warehouse>)(EndInvoke("GetWarehouseCollection", _args, result)));
                return _result;
            }
        }

        #endregion
        
        #region GetSingleWarehouse

        public event EventHandler<SingleFeedbackCompletedEventArgs<Warehouse>> GetSingleWarehouseCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginGetSingleWarehouse(int warehouseID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginGetSingleWarehouse(warehouseID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<Warehouse> IInventoryService.EndGetSingleWarehouse(IAsyncResult result)
        {
            return Channel.EndGetSingleWarehouse(result);
        }

        private IAsyncResult OnBeginGetSingleWarehouse(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int warehouseID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginGetSingleWarehouse(warehouseID, callback, asyncState);
        }

        private object[] OnEndGetSingleWarehouse(IAsyncResult result)
        {
            SingleFeedback<Warehouse> retVal = ((IInventoryService)(this)).EndGetSingleWarehouse(result);
            return new object[] { retVal };
        }

        private void OnGetSingleWarehouseCompleted(object state)
        {
            if ((GetSingleWarehouseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                GetSingleWarehouseCompleted(this, new SingleFeedbackCompletedEventArgs<Warehouse>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetSingleWarehouseAsync(int warehouseID)
        {
            GetSingleWarehouseAsync(warehouseID, null);
        }

        public void GetSingleWarehouseAsync(int warehouseID, object userState)
        {
            if ((onBeginGetSingleWarehouseDelegate == null))
            {
                onBeginGetSingleWarehouseDelegate = new BeginOperationDelegate(OnBeginGetSingleWarehouse);
            }
            if ((onEndGetSingleWarehouseDelegate == null))
            {
                onEndGetSingleWarehouseDelegate = new EndOperationDelegate(OnEndGetSingleWarehouse);
            }
            if ((onGetSingleWarehouseCompletedDelegate == null))
            {
                onGetSingleWarehouseCompletedDelegate = new SendOrPostCallback(OnGetSingleWarehouseCompleted);
            }
            InvokeAsync(onBeginGetSingleWarehouseDelegate, new object[] {
                                                                                    warehouseID}, onEndGetSingleWarehouseDelegate, onGetSingleWarehouseCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetSingleWarehouseDelegate;

        private EndOperationDelegate onEndGetSingleWarehouseDelegate;

        private SendOrPostCallback onGetSingleWarehouseCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginGetSingleWarehouse(int warehouseID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = warehouseID;

                IAsyncResult _result = BeginInvoke("GetSingleWarehouse", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<Warehouse> EndGetSingleWarehouse(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<Warehouse> _result = ((SingleFeedback<Warehouse>)(EndInvoke("GetSingleWarehouse", _args, result)));
                return _result;
            }
        }

        #endregion

        #region InsertWarehouse

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertWarehouseCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginInsertWarehouse(Warehouse data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginInsertWarehouse(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<int> IInventoryService.EndInsertWarehouse(IAsyncResult result)
        {
            return Channel.EndInsertWarehouse(result);
        }

        private IAsyncResult OnBeginInsertWarehouse(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Warehouse data = (Warehouse)inValues[0];

            return ((IInventoryService)(this)).BeginInsertWarehouse(data, callback, asyncState);
        }

        private object[] OnEndInsertWarehouse(IAsyncResult result)
        {
            SingleFeedback<int> retVal = ((IInventoryService)(this)).EndInsertWarehouse(result);
            return new object[] { retVal };
        }

        private void OnInsertWarehouseCompleted(object state)
        {
            if ((InsertWarehouseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                InsertWarehouseCompleted(this, new SingleFeedbackCompletedEventArgs<int>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void InsertWarehouseAsync(Warehouse data)
        {
            InsertWarehouseAsync(data, null);
        }

        public void InsertWarehouseAsync(Warehouse data, object userState)
        {
            if ((onBeginInsertWarehouseDelegate == null))
            {
                onBeginInsertWarehouseDelegate = new BeginOperationDelegate(OnBeginInsertWarehouse);
            }
            if ((onEndInsertWarehouseDelegate == null))
            {
                onEndInsertWarehouseDelegate = new EndOperationDelegate(OnEndInsertWarehouse);
            }
            if ((onInsertWarehouseCompletedDelegate == null))
            {
                onInsertWarehouseCompletedDelegate = new SendOrPostCallback(OnInsertWarehouseCompleted);
            }
            InvokeAsync(onBeginInsertWarehouseDelegate, new object[] {
                                                                                 data}, onEndInsertWarehouseDelegate, onInsertWarehouseCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginInsertWarehouseDelegate;

        private EndOperationDelegate onEndInsertWarehouseDelegate;

        private SendOrPostCallback onInsertWarehouseCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginInsertWarehouse(Warehouse data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("InsertWarehouse", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<int> EndInsertWarehouse(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<int> _result = ((SingleFeedback<int>)(EndInvoke("InsertWarehouse", _args, result)));
                return _result;
            }
        }

        #endregion

        #region UpdateWarehouse

        public event EventHandler<FeedbackCompletedEventArgs> UpdateWarehouseCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUpdateWarehouse(Warehouse data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUpdateWarehouse(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUpdateWarehouse(IAsyncResult result)
        {
            return Channel.EndUpdateWarehouse(result);
        }

        private IAsyncResult OnBeginUpdateWarehouse(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Warehouse data = (Warehouse)inValues[0];

            return ((IInventoryService)(this)).BeginUpdateWarehouse(data, callback, asyncState);
        }

        private object[] OnEndUpdateWarehouse(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUpdateWarehouse(result);
            return new object[] { retVal };
        }

        private void OnUpdateWarehouseCompleted(object state)
        {
            if ((UpdateWarehouseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UpdateWarehouseCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UpdateWarehouseAsync(Warehouse data)
        {
            UpdateWarehouseAsync(data, null);
        }

        public void UpdateWarehouseAsync(Warehouse data, object userState)
        {
            if ((onBeginUpdateWarehouseDelegate == null))
            {
                onBeginUpdateWarehouseDelegate = new BeginOperationDelegate(OnBeginUpdateWarehouse);
            }
            if ((onEndUpdateWarehouseDelegate == null))
            {
                onEndUpdateWarehouseDelegate = new EndOperationDelegate(OnEndUpdateWarehouse);
            }
            if ((onUpdateWarehouseCompletedDelegate == null))
            {
                onUpdateWarehouseCompletedDelegate = new SendOrPostCallback(OnUpdateWarehouseCompleted);
            }
            InvokeAsync(onBeginUpdateWarehouseDelegate, new object[] {
                                                                                 data}, onEndUpdateWarehouseDelegate, onUpdateWarehouseCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUpdateWarehouseDelegate;

        private EndOperationDelegate onEndUpdateWarehouseDelegate;

        private SendOrPostCallback onUpdateWarehouseCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUpdateWarehouse(Warehouse data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("UpdateWarehouse", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUpdateWarehouse(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UpdateWarehouse", _args, result)));
                return _result;
            }
        }

        #endregion

        #region DeleteWarehouse

        public event EventHandler<FeedbackCompletedEventArgs> DeleteWarehouseCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginDeleteWarehouse(int data, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginDeleteWarehouse(data, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndDeleteWarehouse(IAsyncResult result)
        {
            return Channel.EndDeleteWarehouse(result);
        }

        private IAsyncResult OnBeginDeleteWarehouse(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int data = (int)inValues[0];

            return ((IInventoryService)(this)).BeginDeleteWarehouse(data, callback, asyncState);
        }

        private object[] OnEndDeleteWarehouse(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndDeleteWarehouse(result);
            return new object[] { retVal };
        }

        private void OnDeleteWarehouseCompleted(object state)
        {
            if ((DeleteWarehouseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                DeleteWarehouseCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void DeleteWarehouseAsync(int data)
        {
            DeleteWarehouseAsync(data, null);
        }

        public void DeleteWarehouseAsync(int data, object userState)
        {
            if ((onBeginDeleteWarehouseDelegate == null))
            {
                onBeginDeleteWarehouseDelegate = new BeginOperationDelegate(OnBeginDeleteWarehouse);
            }
            if ((onEndDeleteWarehouseDelegate == null))
            {
                onEndDeleteWarehouseDelegate = new EndOperationDelegate(OnEndDeleteWarehouse);
            }
            if ((onDeleteWarehouseCompletedDelegate == null))
            {
                onDeleteWarehouseCompletedDelegate = new SendOrPostCallback(OnDeleteWarehouseCompleted);
            }
            InvokeAsync(onBeginDeleteWarehouseDelegate, new object[] {
                                                                                 data}, onEndDeleteWarehouseDelegate, onDeleteWarehouseCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginDeleteWarehouseDelegate;

        private EndOperationDelegate onEndDeleteWarehouseDelegate;

        private SendOrPostCallback onDeleteWarehouseCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginDeleteWarehouse(int data, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = data;

                IAsyncResult _result = BeginInvoke("DeleteWarehouse", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndDeleteWarehouse(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("DeleteWarehouse", _args, result)));
                return _result;
            }
        }

        #endregion

        #region SearchWarehouse

        public event EventHandler<CollectionFeedbackCompletedEventArgs<Warehouse>> SearchWarehouseCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginSearchWarehouse(Warehouse criteria, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginSearchWarehouse(criteria, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<Warehouse> IInventoryService.EndSearchWarehouse(IAsyncResult result)
        {
            return Channel.EndSearchWarehouse(result);
        }

        private IAsyncResult OnBeginSearchWarehouse(object[] inValues, AsyncCallback callback, object asyncState)
        {
            Warehouse criteria = (Warehouse)inValues[0];

            return ((IInventoryService)(this)).BeginSearchWarehouse(criteria, callback, asyncState);
        }

        private object[] OnEndSearchWarehouse(IAsyncResult result)
        {
            CollectionFeedback<Warehouse> retVal = ((IInventoryService)(this)).EndSearchWarehouse(result);
            return new object[] { retVal };
        }

        private void OnSearchWarehouseCompleted(object state)
        {
            if ((SearchWarehouseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                SearchWarehouseCompleted(this, new CollectionFeedbackCompletedEventArgs<Warehouse>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void SearchWarehouseAsync(Warehouse criteria)
        {
            SearchWarehouseAsync(criteria, null);
        }

        public void SearchWarehouseAsync(Warehouse criteria, object userState)
        {
            if ((onBeginSearchWarehouseDelegate == null))
            {
                onBeginSearchWarehouseDelegate = new BeginOperationDelegate(OnBeginSearchWarehouse);
            }
            if ((onEndSearchWarehouseDelegate == null))
            {
                onEndSearchWarehouseDelegate = new EndOperationDelegate(OnEndSearchWarehouse);
            }
            if ((onSearchWarehouseCompletedDelegate == null))
            {
                onSearchWarehouseCompletedDelegate = new SendOrPostCallback(OnSearchWarehouseCompleted);
            }
            InvokeAsync(onBeginSearchWarehouseDelegate, new object[] {
                                                                                 criteria}, onEndSearchWarehouseDelegate, onSearchWarehouseCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginSearchWarehouseDelegate;

        private EndOperationDelegate onEndSearchWarehouseDelegate;

        private SendOrPostCallback onSearchWarehouseCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginSearchWarehouse(Warehouse criteria, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = criteria;

                IAsyncResult _result = BeginInvoke("SearchWarehouse", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<Warehouse> EndSearchWarehouse(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<Warehouse> _result = ((CollectionFeedback<Warehouse>)(EndInvoke("SearchWarehouse", _args, result)));
                return _result;
            }
        }

        #endregion

        #region UndoDeleteWarehouse

        public event EventHandler<FeedbackCompletedEventArgs> UndoDeleteWarehouseCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IInventoryService.BeginUndoDeleteWarehouse(int objID, AsyncCallback callback, object asyncState)
        {
            return Channel.BeginUndoDeleteWarehouse(objID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        Feedback IInventoryService.EndUndoDeleteWarehouse(IAsyncResult result)
        {
            return Channel.EndUndoDeleteWarehouse(result);
        }

        private IAsyncResult OnBeginUndoDeleteWarehouse(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int objID = (int)inValues[0];

            return ((IInventoryService)(this)).BeginUndoDeleteWarehouse(objID, callback, asyncState);
        }

        private object[] OnEndUndoDeleteWarehouse(IAsyncResult result)
        {
            Feedback retVal = ((IInventoryService)(this)).EndUndoDeleteWarehouse(result);
            return new object[] { retVal };
        }

        private void OnUndoDeleteWarehouseCompleted(object state)
        {
            if ((UndoDeleteWarehouseCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                UndoDeleteWarehouseCompleted(this, new FeedbackCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void UndoDeleteWarehouseAsync(int objID)
        {
            UndoDeleteWarehouseAsync(objID, null);
        }

        public void UndoDeleteWarehouseAsync(int objID, object userState)
        {
            if ((onBeginUndoDeleteWarehouseDelegate == null))
            {
                onBeginUndoDeleteWarehouseDelegate = new BeginOperationDelegate(OnBeginUndoDeleteWarehouse);
            }
            if ((onEndUndoDeleteWarehouseDelegate == null))
            {
                onEndUndoDeleteWarehouseDelegate = new EndOperationDelegate(OnEndUndoDeleteWarehouse);
            }
            if ((onUndoDeleteWarehouseCompletedDelegate == null))
            {
                onUndoDeleteWarehouseCompletedDelegate = new SendOrPostCallback(OnUndoDeleteWarehouseCompleted);
            }
            InvokeAsync(onBeginUndoDeleteWarehouseDelegate, new object[] {
                    objID}, onEndUndoDeleteWarehouseDelegate, onUndoDeleteWarehouseCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginUndoDeleteWarehouseDelegate;

        private EndOperationDelegate onEndUndoDeleteWarehouseDelegate;

        private SendOrPostCallback onUndoDeleteWarehouseCompletedDelegate;

        private partial class InventoryServiceClientChannel
        {
            public IAsyncResult BeginUndoDeleteWarehouse(int objID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = objID;

                IAsyncResult _result = BeginInvoke("UndoDeleteWarehouse", _args, callback, asyncState);
                return _result;
            }

            public Feedback EndUndoDeleteWarehouse(IAsyncResult result)
            {
                object[] _args = new object[0];
                Feedback _result = ((Feedback)(EndInvoke("UndoDeleteWarehouse", _args, result)));
                return _result;
            }
        }

        #endregion

    }
}